import BIM from "../BIM";
import CameraView from "../camera/CameraView";
import { VIEW } from "../const/const";
import EditorScene from "../scene/EditorScene";

export default class SceneManager {

    constructor(){
        this.scene = new EditorScene();
        this.cameraView = new CameraView();
        this.createNormalControls();
    }

    dispose() {
        if(this.scene){
            this.scene.dispose();
            this.scene = null;
        }
    }

    createNormalControls() {

       
        this.cameraView.createNormalControls(this.scene.camera, this.scene.css2drender.domElement);
    }

    createDrawControls() {

        this.cameraView.createDrawControls(this.scene.css2drender.domElement);
    }


    mountedMainScene() {
        console.log("mounted editor scene.")
        BIM.container.appendChild(this.scene._render.domElement);
        BIM.container.appendChild(this.scene._css2dReder.domElement);
    }

    unmountedMainScene() {
        BIM.container.removeChild(this.scene._render.domElement);
        BIM.container.removeChild(this.scene._css2dReder.domElement);
    }

    onResize(){
        if(this.scene)this.scene.onResize();
    }

    changeView(view) {

        // 分三种： 顶视图（绘图模式）, 鸟瞰图（常规模式）, 漫游模式
        switch (view) {
            case VIEW.drawview:
                this.createDrawControls()
                break;
            case VIEW.roamview:

                break;
            default:
                this.createNormalControls()
                break;
        }


    }

}